package cn.crap.service.table;

import cn.crap.framework.base.BaseService;
import cn.crap.framework.base.IBaseDao;
import cn.crap.inter.dao.IArticleDao;
import cn.crap.inter.service.table.IArticleService;
import cn.crap.inter.service.tool.ILuceneService;
import cn.crap.model.Article;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ArticleService extends BaseService<Article>
        implements IArticleService, ILuceneService<Article> {
    @Resource(name = "articleDao")
    IArticleDao webPageDao;

    @Resource(name = "articleDao")
    public void setDao(IBaseDao<Article> dao) {
        super.setDao(dao);
    }

    @Override
    @Transactional
    public Article get(String id) {
        Article model = dao.get(id);
        if (model == null)
            return new Article();
        return model;
    }

    @Override
    @Transactional
    public List<Article> getAll() {
        return webPageDao.findByMap(null, null, null);
    }

    @Override
    public String getLuceneType() {
        return "文章&数据字典";
    }


}
